package org.bigk.invoices.utils;

import org.apache.commons.lang.StringUtils;

public class TextUtils {

	public static String convert2HtmlText(String res) {
		if (StringUtils.isNotEmpty(res)) {
			res = res.replaceAll("\\r\\n", "<br/>");
			res = res.replaceAll("\\r", "<br/>");
			res = res.replaceAll("\\n", "<br/>");
		}
		return res;
	}

	public static String convert2JsText(String res) {
		if (StringUtils.isNotEmpty(res)) {
			res = res.replaceAll("\\r\\n", "\\\\n");
			res = res.replaceAll("\\r", "\\n");
			res = res.replaceAll("\\n", "\\n");
			res = res.replaceAll("\"", "\" + '\"' + \"");
		}
		return res;
	}
}
